This notebook analyzes global urbanization trends, life expectancy, GDP per capita, and their relationships using data visualizations.
Author
Piyush Rajendra Jain
Published
April 27, 2025
Explaining the Graphs: Urbanization, Wealth, and Life
Let’s take a journey through urban development, global wealth, and human well-being — all using data visualization!
Understanding the Modern World: Urbanization, Wealth, and Human Well-being
The past decades have witnessed tremendous shifts in where and how humans live. Urbanization — the movement of humans from rural to urban areas — has fundamentally altered countries economically, socially, and even environmentally.
But urbanization is more than cities growing taller. It is intimately linked with economic prosperity and human well-being. - Do richer countries urbanize more? - Does city living really lead to a longer, healthier life?
In this project, we explore these questions by looking at global data on:
Urban population percentages,
GDP per capita, and
Life expectancy
In a series of visualizations, we show how these powerful forces become intertwined to shape our world today.
Show the code
# Importing all the required packages and libraries to efficiently complete the projectimport pandas as pdimport numpy as npimport matplotlib.pyplot as pltimport seaborn as snsimport geopandas as gpdfrom plotnine import*import ipywidgets as widgetsfrom IPython.display import displayfrom shapely.geometry import Polygon# Reading the csv uploaded to colaburban_data = pd.read_csv('cleaned_unicef_data.csv')
Graph 1: Choropleth Map of Urban Population Share
Here is a world map tinted by the percentage of each country’s population living in cities.
Dark countries are highly urbanized (lots of people live in cities).
Lighter ones, not so much.
This shows us from up high: Where are people aggregating in cities? Which places are still quite rural?
But urbanization is not a lone activity. It touches life — sometimes subtly, sometimes fundamentally. So naturally we ask:
“Do urban living really improve your quality of life?”
Graph 2: Top 10 Countries by Life Expectancy (2020)
We shift our focus to life expectancy — an important measure of well-being.
This bar chart shows the 10 countries with the highest life expectancy in 2020. We can start spotting a pattern: many of these countries are also highly urbanized, suggesting a potential link.
But just looking at the top countries isn’t enough. We need to see the relationship across the whole world.
Show the code
# Filter for 2020data_2020 = urban_df[urban_df['year'] ==2020].dropna(subset=['life_expectancy_at_birth,_total_(years)'])# Group by country and calculate mean life expectancyavg_lifeexp = ( data_2020.groupby("country")["life_expectancy_at_birth,_total_(years)"] .mean() .reset_index(name="avg_life_expectancy"))top10 = avg_lifeexp.nlargest(10, "avg_life_expectancy")# Plotplt.figure(figsize=(10, 6))sns.barplot(data=top10, y="country", x="avg_life_expectancy", palette="viridis")plt.title("Top 10 Countries by Life Expectancy (2020)")plt.xlabel("Average Life Expectancy (Years)")plt.ylabel("Country")plt.tight_layout()plt.show()
Graph 3: Scatter Plot - Urban Population vs Life Expectancy
Here, every point represents a country. We plot urbanization on the x-axis and life expectancy on the y-axis.
The trend line shows us: - More urbanized countries tend to have higher life expectancies!
It’s not a perfect correlation, but the positive relationship is clear.
At this point, we realize wealth might be a hidden player in this story. So we ask:
“Maybe richer countries are both more urbanized and healthier?”
This colorful heatmap shows correlations between different variables:
Urbanization
GDP per capita
Life expectancy
Strong positive or negative colors highlight where tight relationships exist. This gives us a bird’s-eye view of how all these factors interact!
Finally, we tie everything back to our original hypothesis…
Graph 5: Urban Population Trends Over Time
This line graph shows urban growth from 2000 to 2020.
A clear upward trend proves that urbanization is increasing globally, year after year.
Now that we’ve seen urbanization, health, and wealth separately, we want to see how all factors are related to each other at once.
Show the code
countries = ['United States', 'China', 'India', 'Brazil', 'Nigeria', 'Germany']time_data = urban_df[urban_df['country'].isin(countries)]time_data = time_data.sort_values(by=['country', 'year'])# Time series plottime_series_plot = ( ggplot(time_data, aes(x='year', y='share_of_urban_population', color='country')) + geom_line(size=1) + geom_point(size=2) + labs(title='Urban Population Trends Over Time', x='Year', y='Urban Population (%)', color='Country') + theme_minimal() + theme(axis_text_x=element_text(angle=45, hjust=1)))display(time_series_plot)
CONCLUSION
Key Takeaways:
Our visual journey reveals several important insights:
Urbanization is unevenly distributed across the globe, but it’s steadily rising everywhere.
Countries with higher urban populations tend to enjoy longer life expectancies, suggesting better access to healthcare, education, and services.
Economic prosperity (GDP per capita) is strongly linked to both urbanization and life expectancy.
Wealthier, more urbanized nations generally offer better living standards for their populations.
Together, the data paints a clear picture: Urbanization, when combined with economic development, can be a powerful driver of better human outcomes.
However, the benefits are not automatic — thoughtful planning, inclusivity, and sustainability are crucial to ensuring that urban growth leads to a healthier and more equitable world for all.